<?php
/**
 * 
 * 
 * @version $Id: CParameterCriteria.php,v 1.2 2011-05-29 05:37:28 herve Exp $
 * @copyright 2011
 */
class CParameterCriteria {
	private $_parameter;
	private $_result;

	public function __construct($parameter) {
		$this->_parameter = clone $parameter;
		$this->_result = new CParameterResult();
	}

	public function equals($col, $values) {
		if (!is_array($values))
			$values = array (
				$values
			);

		foreach ($this->_parameter as $row) {
			if (array_search($row[$col], $values) !== false)
				$this->_result->append($row);
		}

		return $this;
	}

	public function result() {
		if (count($this->_result) == 0)
			return null;
		else
			return $this->_result;
	}

	public function first() {
		return $this->_result->first();
	}

	public function clear() {
		$this->_result->clear();
	}
}
?>
